package com.playball.lottery.customview;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.NetworkInfo.State;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.playball.lottery.R;
import com.playball.lottery.ApplicationData;
import com.playball.lottery.JddMainActivity;
import com.playball.lottery.eventmanger.EventManager;
import com.playball.lottery.eventmanger.EventType;
import com.playball.lottery.frm.buyhall.BDxhlbActivity;
import com.playball.lottery.frm.buyhall.CQSSCListActivity;
import com.playball.lottery.frm.buyhall.DltxhlbActivity;
import com.playball.lottery.frm.buyhall.ElvSelFiveListActivity;
import com.playball.lottery.frm.buyhall.ElvYunDJListActivity;
import com.playball.lottery.frm.buyhall.Fc3dListActivity;
import com.playball.lottery.frm.buyhall.IntelligenceChaseActivity;
import com.playball.lottery.frm.buyhall.JcBasketballxhlbActivity;
import com.playball.lottery.frm.buyhall.JcfootxhlbActivity;
import com.playball.lottery.frm.buyhall.Kuai3ListActivity;
import com.playball.lottery.frm.buyhall.N7lxhlbActivity;
import com.playball.lottery.frm.buyhall.N7xxhlbActivity;
import com.playball.lottery.frm.buyhall.Pailie3ListActivity;
import com.playball.lottery.frm.buyhall.Pailie5ListActivity;
import com.playball.lottery.frm.buyhall.SsqxhlbActivity;
import com.playball.lottery.frm.hemai.HeMaiDetailActivity;
import com.playball.lottery.frm.yhzx.BetRecordActivity;
import com.playball.lottery.frm.yhzx.JddRechargeListActivity;
import com.playball.lottery.frm.yhzx.ZhRecordActivity;
import com.playball.lottery.frm.yhzx.JddRegisterActivity.loginAsyncLoader;
import com.playball.lottery.nt.GetJsonData;
import com.playball.lottery.util.Constants;
import com.playball.lottery.util.DefConstants;
import com.playball.lottery.util.FrmWorkStatus;
import com.playball.lottery.util.Logger;
import com.playball.lottery.util.SysApplication;


public class ShowTipDialog implements DefConstants{

	Dialog dialog;
	AlertDialog a_dialog;
	NetworkInfo info;
	Context Mcontext;
	View view_narmal;
	View view;
	boolean success = false;

	// 开启加载框......
	public boolean showDialog(Context context) {
		this.Mcontext = context;
		// 是否联网网络
		ConnectivityManager manger = (ConnectivityManager) Mcontext.getSystemService(Context.CONNECTIVITY_SERVICE);
		NetworkInfo info = manger.getActiveNetworkInfo();

		// 检查当前是否有网络
		if (info != null && info.isAvailable()) {
			State wifi_state = manger.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
			State moblie_state = manger.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
			if (State.CONNECTED == wifi_state) {
				success = true;
			} else if (State.CONNECTED == moblie_state) {
				success = true;
			} else {
				success = false;
			}
		} else {
			success = false;
		}
		if (success) {
			dialog = new Dialog(Mcontext, R.style.dialog);
			LayoutInflater inflater = LayoutInflater.from(context);
			View v = inflater.inflate(R.layout.show_dialog_narmal, null);
			LinearLayout layout = (LinearLayout) v.findViewById(R.id.show_dialog);
			ImageView spaceshipImage = (ImageView) v.findViewById(R.id.img_loading);
			Animation hyperspaceJumpAnimation = AnimationUtils.loadAnimation(
					context, R.anim.animation);
			spaceshipImage.startAnimation(hyperspaceJumpAnimation);
			dialog.setContentView(layout, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
					LinearLayout.LayoutParams.WRAP_CONTENT));
			dialog.setCanceledOnTouchOutside(false);
			dialog.show();
			return true;
		} else {
			
			
			
			ShowCustomDialog.Builder alertbBuilder =  new ShowCustomDialog.Builder(context);
			alertbBuilder.setTitle("未打开网络");
			alertbBuilder.setMessage("请打开您的网络连接，稍后再试!");
			alertbBuilder.setNegativeButton("网络设置", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					Mcontext.startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
					dialog.cancel();
				}
			}).setPositiveButton("退出", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					SysApplication.getInstance().exit();
					 dialog.cancel();
				}
			}) 
			.createCustomDialog().show();;
			
	 
			return false;
		}
	}

	// 关闭加载框......
	public void closeDialog() {
		if (dialog != null) {
			dialog.dismiss();
		}
		if (a_dialog != null) {
			// a_dialog.dismiss();
		}
	}
	
	
	
	// 弹出购买后的提示框
	public void showBuyInfo(final Context context, String msg, String tip, int drawable_id,final String params) {
		// 跳转至-开奖信息主页面
		ShowCustomDialog.Builder alertbBuilder = new ShowCustomDialog.Builder(context);
		alertbBuilder.setTitle(tip);
		
		//alertbBuilder.setIcon(drawable_id);
		if (tip.equals("购买失败")) {
			//余额不足
			if (msg.contains(Constants.BALANCE_BUZU)) {
				alertbBuilder.setMessage("您的余额不足，需要充值后再去购买！");
				alertbBuilder.setNegativeButton("充值", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						Intent intent1= new Intent();        
					    intent1.setAction("android.intent.action.VIEW");    
					    Uri content_url = Uri.parse(GetJsonData.urlPath_recharge+ApplicationData.getInstance().getUserID());   
					    intent1.setData(content_url);  
					    context.startActivity(intent1);
						dialog.dismiss();
					}
				}).setPositiveButton("取消", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.dismiss();
					}
				}) 
				.createCustomDialog().show();
				
				
				
//				alertbBuilder.setMessage(Constants.BALANCE_SHOW_NOT_MONEY_STR);
//				alertbBuilder.setNegativeButton("立即购买", new DialogInterface.OnClickListener() {
//					@Override
//					public void onClick(DialogInterface dialog, int which) {
//						Intent intent = new Intent();
//						 intent.setClass(context, JddRechargeListActivity.class);
//						 intent.putExtra("params", params);
//						 ((Activity)context).startActivityForResult(intent, REQ_CODE_NO_MONEY_2_RECHARGE);
//						 dialog.dismiss();
//					}
//				}).setPositiveButton("充值", new DialogInterface.OnClickListener() {
//					@Override
//					public void onClick(DialogInterface dialog, int which) {
//						// TODO Auto-generated method stub
//						Intent intent = new Intent();
//						 intent.setClass(context, JddRechargeListActivity.class);
//						 context.startActivity(intent);
//						 dialog.dismiss();
//					}
//				}) 
//				.createCustomDialog().show();
			}
			//赛事编号
			else if (msg.contains(Constants.BALANCE_LATER)) {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.dismiss();;
				
					}
				}) 
				.createCustomDialog().show();
			}
			//期次销售停止
			else if (msg.contains(Constants.BALANCE_CUT)) {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.cancel();
				
					}
				}) 
				.createCustomDialog().show();
			}
			//系统忙
			else if (msg.contains(Constants.BALANCE_SYSTEM_EXC)) {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.cancel();
				
					}
				}) 
				.createCustomDialog().show();
			}
			//该期投注 
			else if (msg.contains(Constants.BALANCE_CURRISS_STOP)) {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.cancel();
				
					}
				}) 
				.createCustomDialog().show();
			}
			else {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.cancel();
				
					}
				}) 
				.createCustomDialog().show();
			}
			
		} else {
			alertbBuilder.setMessage(msg);
			alertbBuilder.setPositiveButton("投注记录", new DialogInterface.OnClickListener() {
			
				public void onClick(DialogInterface dialog, int which) {
					// 获得自定义的应用程序BallDTO,初始化
					ApplicationData.getInstance().initList();
					
					Intent intent = new Intent();
					intent.setClass(context, BetRecordActivity.class);
					context.startActivity(intent);
					
					if (!context.getClass().equals(JddMainActivity.class)) {
						((Activity)context).setResult(Activity.RESULT_OK);
						((Activity)context).finish();
					} 
					
//					//传统足球 - 胜负彩
//					if (context.getClass().equals(CtzqSfcActivity.class)) {
//						((CtzqSfcActivity) context).setResult(Activity.RESULT_OK);
//						((CtzqSfcActivity) context).finish();
//					}
//					//传统足球 - 任选9
//					if (context.getClass().equals(CtzqRx9Activity.class)) {
//						((CtzqRx9Activity) context).setResult(Activity.RESULT_OK);
//						((CtzqRx9Activity) context).finish();
//					}
//					
//					//发起合买
//					if (context.getClass().equals(FaQiHeMaiActivity.class)) {
//						((FaQiHeMaiActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiActivity) context).finish();
//					}
					
//					Intent intent = new Intent();
//					intent.setClass(context, BetRecordActivity.class);
//					context.startActivity(intent);
//					if (context.getClass().equals(FaQiHeMaiActivity.class)) {
//						((FaQiHeMaiActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCActivity.class)) {
//						((FaQiHeMaiJCActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCZQHHActivity.class)) {
//						((FaQiHeMaiJCZQHHActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCLQHHActivity.class)) {
//						((FaQiHeMaiJCLQHHActivity) context).finish();
//					}
					if (context.getClass().equals(SsqxhlbActivity.class)) {
						((SsqxhlbActivity) context).finish();
					} else if (context.getClass().equals(DltxhlbActivity.class)) {
						((DltxhlbActivity) context).finish();
					} else if (context.getClass().equals(ElvSelFiveListActivity.class)) {
						((ElvSelFiveListActivity) context).finish();
					} else if (context.getClass().equals(ElvYunDJListActivity.class)) {
						((ElvYunDJListActivity) context).finish();
					} else if (context.getClass().equals(CQSSCListActivity.class)) {
						((CQSSCListActivity) context).finish();
					} else if (context.getClass().equals(JcfootxhlbActivity.class)) {
						((JcfootxhlbActivity) context).finish();
					} else if (context.getClass().equals(BDxhlbActivity.class)) {
						((BDxhlbActivity) context).finish();
					} else if (context.getClass().equals(Fc3dListActivity.class)) {
						((Fc3dListActivity) context).finish();
					} else if (context.getClass().equals(JcBasketballxhlbActivity.class)) {
						((JcBasketballxhlbActivity) context).finish();
					} else if (context.getClass().equals(N7lxhlbActivity.class)) {
						((N7lxhlbActivity) context).finish();
					} else if (context.getClass().equals(N7xxhlbActivity.class)) {
						((N7xxhlbActivity) context).finish();
					} else if (context.getClass().equals(Pailie3ListActivity.class)) {
						((Pailie3ListActivity) context).finish();
					} else if (context.getClass().equals(Pailie5ListActivity.class)) {
						((Pailie5ListActivity) context).finish();
					}  else if (context.getClass().equals(IntelligenceChaseActivity.class)) {
						((IntelligenceChaseActivity) context).finish();
					} 
//					else if (context.getClass().equals(Zqrx9xhlbActivity.class)) {
//						((Zqrx9xhlbActivity) context).finish();
//					} else if (context.getClass().equals(ZqsfcxhlbActivity.class)) {
//						((ZqsfcxhlbActivity) context).finish();
//					} else if (context.getClass().equals(JclqHhtzDetail.class)) {
//						((JclqHhtzDetail) context).finish();
//					}else if (context.getClass().equals(JczqHhtzDetail.class)) {
//						((JczqHhtzDetail) context).finish();
//					}
					 dialog.cancel();
				}
				
			}).setNegativeButton("购彩大厅", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					

					// 获得自定义的应用程序BallDTO,初始化
					ApplicationData.getInstance().initList();
					
					 Intent intent = new Intent();
					 intent.setClass(context, JddMainActivity.class);
					 context.startActivity(intent);
					 
					 EventManager.getInstance().onEvent(EventType.EV_UI_FRM_MAIN_JUMP, FrmWorkStatus.MAINHOME);
					 EventManager.getInstance().onEvent(EventType.EV_UI_BLL_SCROLL_TO_MIDDLE, FrmWorkStatus.MAINHOME);
					 
					 //从广告页面进入的购彩，自动隐藏下拉广告
					 EventManager.getInstance().onEvent(EventType.EV_BLL_UI_MAIN_BANNER_OUT, null);
					 EventManager.getInstance().onEvent(EventType.EV_BLL_UI_MAIN_BANNER_HIDE, null);
					 
//					if (context.getClass().equals(SsqxhlbActivity.class)) {
//						((SsqxhlbActivity) context).setResult(Activity.RESULT_OK);
//						((SsqxhlbActivity) context).finish();
//					}
//					
//					//传统足球 - 胜负彩
//					if (context.getClass().equals(CtzqSfcActivity.class)) {
//						((CtzqSfcActivity) context).setResult(Activity.RESULT_OK);
//						((CtzqSfcActivity) context).finish();
//					}
//					//传统足球 - 任选9
//					if (context.getClass().equals(CtzqRx9Activity.class)) {
//						((CtzqRx9Activity) context).setResult(Activity.RESULT_OK);
//						((CtzqRx9Activity) context).finish();
//					}
//					
//					//发起合买
//					if (context.getClass().equals(FaQiHeMaiActivity.class)) {
//						((FaQiHeMaiActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiActivity) context).finish();
//					}
					
					
//					if (context.getClass().equals(FaQiHeMaiActivity.class)) {
//						((FaQiHeMaiActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCActivity.class)) {
//						((FaQiHeMaiJCActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiJCActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCZQHHActivity.class)) {
//						((FaQiHeMaiJCZQHHActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiJCZQHHActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCLQHHActivity.class)) {
//						((FaQiHeMaiJCLQHHActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiJCLQHHActivity) context).finish();
//					}
					if (context.getClass().equals(SsqxhlbActivity.class)) {
						((SsqxhlbActivity) context).setResult(Activity.RESULT_OK);
						((SsqxhlbActivity) context).finish();
					} else if (context.getClass().equals(DltxhlbActivity.class)) {
						((DltxhlbActivity) context).setResult(Activity.RESULT_OK);
						((DltxhlbActivity) context).finish();
					} else if (context.getClass().equals(ElvSelFiveListActivity.class)) {
						((ElvSelFiveListActivity) context).setResult(Activity.RESULT_OK);
						((ElvSelFiveListActivity) context).finish();
					} else if (context.getClass().equals(ElvYunDJListActivity.class)) {
						((ElvYunDJListActivity) context).setResult(Activity.RESULT_OK);
						((ElvYunDJListActivity) context).finish();
					} else if (context.getClass().equals(CQSSCListActivity.class)) {
						((CQSSCListActivity) context).setResult(Activity.RESULT_OK);
						((CQSSCListActivity) context).finish();
					} else if (context.getClass().equals(JcfootxhlbActivity.class)) {
						((JcfootxhlbActivity) context).setResult(Activity.RESULT_OK);
						((JcfootxhlbActivity) context).finish();
					} else if (context.getClass().equals(BDxhlbActivity.class)) {
						((BDxhlbActivity) context).setResult(Activity.RESULT_OK);
						((BDxhlbActivity) context).finish();
					} else if (context.getClass().equals(Fc3dListActivity.class)) {
						((Fc3dListActivity) context).setResult(Activity.RESULT_OK);
						((Fc3dListActivity) context).finish();
					} else if (context.getClass().equals(JcBasketballxhlbActivity.class)) {
						((JcBasketballxhlbActivity) context).setResult(Activity.RESULT_OK);
						((JcBasketballxhlbActivity) context).finish();
					} else if (context.getClass().equals(N7lxhlbActivity.class)) {
						((N7lxhlbActivity) context).setResult(Activity.RESULT_OK);
						((N7lxhlbActivity) context).finish();
					} else if (context.getClass().equals(N7xxhlbActivity.class)) {
						((N7xxhlbActivity) context).setResult(Activity.RESULT_OK);
						((N7xxhlbActivity) context).finish();
					} else if (context.getClass().equals(Pailie3ListActivity.class)) {
						((Pailie3ListActivity) context).setResult(Activity.RESULT_OK);
						((Pailie3ListActivity) context).finish();
					} else if (context.getClass().equals(Pailie5ListActivity.class)) {
						((Pailie5ListActivity) context).setResult(Activity.RESULT_OK);
						((Pailie5ListActivity) context).finish();
					}else if (context.getClass().equals(JddMainActivity.class)) {
						
					} else{
						((Activity)context).setResult(Activity.RESULT_OK);
						((Activity)context).finish();
					}
//					else if (context.getClass().equals(Zqrx9xhlbActivity.class)) {
//						((Zqrx9xhlbActivity) context).setResult(Activity.RESULT_OK);
//						((Zqrx9xhlbActivity) context).finish();
//					} else if (context.getClass().equals(ZqsfcxhlbActivity.class)) {
//						((ZqsfcxhlbActivity) context).setResult(Activity.RESULT_OK);
//						((ZqsfcxhlbActivity) context).finish();
//					}
//					else if (context.getClass().equals(JclqHhtzDetail.class)) {
//						((JclqHhtzDetail) context).setResult(Activity.RESULT_OK);
//						((JclqHhtzDetail) context).finish();
//					}else if (context.getClass().equals(JczqHhtzDetail.class)) {
//						((JczqHhtzDetail) context).setResult(Activity.RESULT_OK);
//						((JczqHhtzDetail) context).finish();
//					}
					
					 dialog.cancel();
				
					
				}
			}) .createCustomDialog().show();;
		}
/*	  Dialog dialog = alertbBuilder.createCustomDialog();
		dialog.setCanceledOnTouchOutside(false); 
		dialog.setCancelable(true);// 设置back键是否可以取消
	try{
			dialog.show();
		}catch(Exception e){
//			e.printStackTrace();
		}*/
	}
	
	
	// 弹出追号后的提示框
	public void showBuyInfoZH(final Context context, String msg, String tip, int drawable_id,final String params) {
		// 跳转至-开奖信息主页面
		ShowCustomDialog.Builder alertbBuilder = new ShowCustomDialog.Builder(context);
		alertbBuilder.setTitle(tip);
		
		//alertbBuilder.setIcon(drawable_id);
		if (tip.equals("购买失败")) {
			//余额不足
			if (msg.contains(Constants.BALANCE_BUZU)) {
				alertbBuilder.setMessage(Constants.BALANCE_SHOW_NOT_MONEY_STR);
				alertbBuilder.setNegativeButton("充值", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						
						Intent intent = new Intent();
						 intent.setClass(context, JddRechargeListActivity.class);
						 context.startActivity(intent);;
						 dialog.dismiss();
				
					}
				}).setPositiveButton("取消", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						 dialog.dismiss();
					}
				}) 
				.createCustomDialog().show();
			}
			//赛事编号
			else if (msg.contains(Constants.BALANCE_LATER)) {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.dismiss();;
				
					}
				}) 
				.createCustomDialog().show();
			}
			//期次销售停止
			else if (msg.contains(Constants.BALANCE_CUT)) {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.cancel();
				
					}
				}) 
				.createCustomDialog().show();
			}else {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.cancel();
				
					}
				}) 
				.createCustomDialog().show();
			}
			
		} else {
			alertbBuilder.setMessage(msg);
			alertbBuilder.setPositiveButton("追号记录", new DialogInterface.OnClickListener() {
			
				public void onClick(DialogInterface dialog, int which) {
					// 获得自定义的应用程序BallDTO,初始化
					ApplicationData.getInstance().initList();
					
					Intent intent = new Intent();
					intent.setClass(context, ZhRecordActivity.class);
					context.startActivity(intent);
					
					if (!context.getClass().equals(JddMainActivity.class)) {
						((Activity)context).setResult(Activity.RESULT_OK);
						((Activity)context).finish();
					} 
					
//					//传统足球 - 胜负彩
//					if (context.getClass().equals(CtzqSfcActivity.class)) {
//						((CtzqSfcActivity) context).setResult(Activity.RESULT_OK);
//						((CtzqSfcActivity) context).finish();
//					}
//					//传统足球 - 任选9
//					if (context.getClass().equals(CtzqRx9Activity.class)) {
//						((CtzqRx9Activity) context).setResult(Activity.RESULT_OK);
//						((CtzqRx9Activity) context).finish();
//					}
//					
//					//发起合买
//					if (context.getClass().equals(FaQiHeMaiActivity.class)) {
//						((FaQiHeMaiActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiActivity) context).finish();
//					}
					
//					Intent intent = new Intent();
//					intent.setClass(context, BetRecordActivity.class);
//					context.startActivity(intent);
//					if (context.getClass().equals(FaQiHeMaiActivity.class)) {
//						((FaQiHeMaiActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCActivity.class)) {
//						((FaQiHeMaiJCActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCZQHHActivity.class)) {
//						((FaQiHeMaiJCZQHHActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCLQHHActivity.class)) {
//						((FaQiHeMaiJCLQHHActivity) context).finish();
//					}
					if (context.getClass().equals(SsqxhlbActivity.class)) {
						((SsqxhlbActivity) context).finish();
					} else if (context.getClass().equals(DltxhlbActivity.class)) {
						((DltxhlbActivity) context).finish();
					} else if (context.getClass().equals(ElvSelFiveListActivity.class)) {
						((ElvSelFiveListActivity) context).finish();
					} else if (context.getClass().equals(ElvYunDJListActivity.class)) {
						((ElvYunDJListActivity) context).finish();
					} else if (context.getClass().equals(CQSSCListActivity.class)) {
						((CQSSCListActivity) context).finish();
					} else if (context.getClass().equals(JcfootxhlbActivity.class)) {
						((JcfootxhlbActivity) context).finish();
					} else if (context.getClass().equals(BDxhlbActivity.class)) {
						((BDxhlbActivity) context).finish();
					} else if (context.getClass().equals(Fc3dListActivity.class)) {
						((Fc3dListActivity) context).finish();
					} else if (context.getClass().equals(JcBasketballxhlbActivity.class)) {
						((JcBasketballxhlbActivity) context).finish();
					} else if (context.getClass().equals(N7lxhlbActivity.class)) {
						((N7lxhlbActivity) context).finish();
					} else if (context.getClass().equals(N7xxhlbActivity.class)) {
						((N7xxhlbActivity) context).finish();
					} else if (context.getClass().equals(Pailie3ListActivity.class)) {
						((Pailie3ListActivity) context).finish();
					} else if (context.getClass().equals(Pailie5ListActivity.class)) {
						((Pailie5ListActivity) context).finish();
					}
//					else if (context.getClass().equals(Zqrx9xhlbActivity.class)) {
//						((Zqrx9xhlbActivity) context).finish();
//					} else if (context.getClass().equals(ZqsfcxhlbActivity.class)) {
//						((ZqsfcxhlbActivity) context).finish();
//					} else if (context.getClass().equals(JclqHhtzDetail.class)) {
//						((JclqHhtzDetail) context).finish();
//					}else if (context.getClass().equals(JczqHhtzDetail.class)) {
//						((JczqHhtzDetail) context).finish();
//					}
					 dialog.cancel();
				}
				
			}).setNegativeButton("购彩大厅", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					

					// 获得自定义的应用程序BallDTO,初始化
					ApplicationData.getInstance().initList();
					
					 Intent intent = new Intent();
					 intent.setClass(context, JddMainActivity.class);
					 context.startActivity(intent);
					 
					 EventManager.getInstance().onEvent(EventType.EV_UI_FRM_MAIN_JUMP, FrmWorkStatus.MAINHOME);
					 EventManager.getInstance().onEvent(EventType.EV_UI_BLL_SCROLL_TO_MIDDLE, FrmWorkStatus.MAINHOME);
					 
					 //从广告页面进入的购彩，自动隐藏下拉广告
					 EventManager.getInstance().onEvent(EventType.EV_BLL_UI_MAIN_BANNER_OUT, null);
					 EventManager.getInstance().onEvent(EventType.EV_BLL_UI_MAIN_BANNER_HIDE, null);
					 
//					if (context.getClass().equals(SsqxhlbActivity.class)) {
//						((SsqxhlbActivity) context).setResult(Activity.RESULT_OK);
//						((SsqxhlbActivity) context).finish();
//					}
//					
//					//传统足球 - 胜负彩
//					if (context.getClass().equals(CtzqSfcActivity.class)) {
//						((CtzqSfcActivity) context).setResult(Activity.RESULT_OK);
//						((CtzqSfcActivity) context).finish();
//					}
//					//传统足球 - 任选9
//					if (context.getClass().equals(CtzqRx9Activity.class)) {
//						((CtzqRx9Activity) context).setResult(Activity.RESULT_OK);
//						((CtzqRx9Activity) context).finish();
//					}
//					
//					//发起合买
//					if (context.getClass().equals(FaQiHeMaiActivity.class)) {
//						((FaQiHeMaiActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiActivity) context).finish();
//					}
					
					
//					if (context.getClass().equals(FaQiHeMaiActivity.class)) {
//						((FaQiHeMaiActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCActivity.class)) {
//						((FaQiHeMaiJCActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiJCActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCZQHHActivity.class)) {
//						((FaQiHeMaiJCZQHHActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiJCZQHHActivity) context).finish();
//					}
//					if (context.getClass().equals(FaQiHeMaiJCLQHHActivity.class)) {
//						((FaQiHeMaiJCLQHHActivity) context).setResult(Activity.RESULT_OK);
//						((FaQiHeMaiJCLQHHActivity) context).finish();
//					}
					if (context.getClass().equals(SsqxhlbActivity.class)) {
						((SsqxhlbActivity) context).setResult(Activity.RESULT_OK);
						((SsqxhlbActivity) context).finish();
					} else if (context.getClass().equals(DltxhlbActivity.class)) {
						((DltxhlbActivity) context).setResult(Activity.RESULT_OK);
						((DltxhlbActivity) context).finish();
					} else if (context.getClass().equals(ElvSelFiveListActivity.class)) {
						((ElvSelFiveListActivity) context).setResult(Activity.RESULT_OK);
						((ElvSelFiveListActivity) context).finish();
					} else if (context.getClass().equals(ElvYunDJListActivity.class)) {
						((ElvYunDJListActivity) context).setResult(Activity.RESULT_OK);
						((ElvYunDJListActivity) context).finish();
					} else if (context.getClass().equals(CQSSCListActivity.class)) {
						((CQSSCListActivity) context).setResult(Activity.RESULT_OK);
						((CQSSCListActivity) context).finish();
					} else if (context.getClass().equals(JcfootxhlbActivity.class)) {
						((JcfootxhlbActivity) context).setResult(Activity.RESULT_OK);
						((JcfootxhlbActivity) context).finish();
					} else if (context.getClass().equals(BDxhlbActivity.class)) {
						((BDxhlbActivity) context).setResult(Activity.RESULT_OK);
						((BDxhlbActivity) context).finish();
					} else if (context.getClass().equals(Fc3dListActivity.class)) {
						((Fc3dListActivity) context).setResult(Activity.RESULT_OK);
						((Fc3dListActivity) context).finish();
					} else if (context.getClass().equals(JcBasketballxhlbActivity.class)) {
						((JcBasketballxhlbActivity) context).setResult(Activity.RESULT_OK);
						((JcBasketballxhlbActivity) context).finish();
					} else if (context.getClass().equals(N7lxhlbActivity.class)) {
						((N7lxhlbActivity) context).setResult(Activity.RESULT_OK);
						((N7lxhlbActivity) context).finish();
					} else if (context.getClass().equals(N7xxhlbActivity.class)) {
						((N7xxhlbActivity) context).setResult(Activity.RESULT_OK);
						((N7xxhlbActivity) context).finish();
					} else if (context.getClass().equals(Pailie3ListActivity.class)) {
						((Pailie3ListActivity) context).setResult(Activity.RESULT_OK);
						((Pailie3ListActivity) context).finish();
					} else if (context.getClass().equals(Pailie5ListActivity.class)) {
						((Pailie5ListActivity) context).setResult(Activity.RESULT_OK);
						((Pailie5ListActivity) context).finish();
					}else if (context.getClass().equals(JddMainActivity.class)) {
						
					} else{
						((Activity)context).setResult(Activity.RESULT_OK);
						((Activity)context).finish();
					}
//					else if (context.getClass().equals(Zqrx9xhlbActivity.class)) {
//						((Zqrx9xhlbActivity) context).setResult(Activity.RESULT_OK);
//						((Zqrx9xhlbActivity) context).finish();
//					} else if (context.getClass().equals(ZqsfcxhlbActivity.class)) {
//						((ZqsfcxhlbActivity) context).setResult(Activity.RESULT_OK);
//						((ZqsfcxhlbActivity) context).finish();
//					}
//					else if (context.getClass().equals(JclqHhtzDetail.class)) {
//						((JclqHhtzDetail) context).setResult(Activity.RESULT_OK);
//						((JclqHhtzDetail) context).finish();
//					}else if (context.getClass().equals(JczqHhtzDetail.class)) {
//						((JczqHhtzDetail) context).setResult(Activity.RESULT_OK);
//						((JczqHhtzDetail) context).finish();
//					}
					
					 dialog.cancel();
				
					
				}
			}) .createCustomDialog().show();;
		}
/*	  Dialog dialog = alertbBuilder.createCustomDialog();
		dialog.setCanceledOnTouchOutside(false); 
		dialog.setCancelable(true);// 设置back键是否可以取消
	try{
			dialog.show();
		}catch(Exception e){
//			e.printStackTrace();
		}*/
	}
	
	
	/**
	 * 合买大厅弹出购买后的提示框
	 * 
	 * @param context
	 * @param msg
	 * @param tip
	 * @param drawable_id
	 */
	public void showHBuyInfo(final Context context, String msg, String tip, int drawable_id) {
		// 跳转至-开奖信息主页面
		ShowCustomDialog.Builder alertbBuilder = new ShowCustomDialog.Builder(context);
		alertbBuilder.setTitle(tip);
		alertbBuilder.setMessage(msg);
		//alertbBuilder.setIcon(drawable_id);
		if (tip.equals("购买失败")) {
			//余额不足
			if (msg.contains(Constants.BALANCE_EMPTY)) {
				alertbBuilder.setNegativeButton("充值", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						Intent intent = new Intent();
						 intent.setClass(context, JddRechargeListActivity.class);
						 context.startActivity(intent);
						 dialog.dismiss();
					}
				}).setPositiveButton("取消", new  DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.cancel();
					}
					
				})
				.createCustomDialog().show();

			}
			//已发起的
			else if (msg.contains(Constants.BALANCE_ARD_NO_REP)) {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.dismiss();;
				
					}
				}) 
				.createCustomDialog().show();
			}
			//方案认购金额
			else if (msg.contains(Constants.BALANCE_MONY_LEAST)) {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.cancel();
				
					}
				}) 
				.createCustomDialog().show();
			}else {
				alertbBuilder.setMessage(msg);
				alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						 dialog.cancel();
				
					}
				}) 
				.createCustomDialog().show();
			}
			
		}else if (tip.equals("温馨提示")) {
			alertbBuilder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					 dialog.dismiss();
				}
			}) .createCustomDialog().show();
		}
		else {
			alertbBuilder.setPositiveButton("合买大厅", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					//快捷购买框
//					if (context.getClass().equals(HeMaiMainActivity.class)) {
//						// 刷新界面,可购买额改变
////						Intent intent = ((HeMaiMainActivity) context).getIntent();
////						context.startActivity(intent);
//						
//						Intent intent12 = new Intent(context, MainActivity.class);
//						intent12.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//						intent12.putExtra("ScreenID", "1");
//						((HeMaiMainActivity) context).startActivityForResult(intent12, REQ_CODE_HEMAIMAIN);
//						
//						
//
//					} else if (context.getClass().equals(HeMaiDetailActivity.class)) {
//
//						// 跳转到合买大厅页面，刷新可购买额
////						Intent intent = new Intent(context, HeMaiMainActivity.class);
////						context.startActivity(intent);
////						((HeMaiDetailActivity) context).finish();// 销毁对象
//						
//						Intent intent12 = new Intent(context, MainActivity.class);
//						intent12.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
//						intent12.putExtra("ScreenID", "1");
//						((HeMaiDetailActivity) context).startActivityForResult(intent12, REQ_CODE_HEMAIDETAIL);
//						((HeMaiDetailActivity) context).finish();// 销毁对象
//						
//					}
					
					if (context.getClass().equals(JddMainActivity.class)) {
						dialog.dismiss();
						
//						Intent intent = new Intent();
//						 intent.setClass(context, JddMainActivity.class);
//						 context.startActivity(intent);

						 EventManager.getInstance().onEvent(EventType.EV_UI_FRM_MAIN_JUMP, FrmWorkStatus.HEMAI_CENTER);
						((Activity)context).setResult(Activity.RESULT_OK);
						
//						((JddMainActivity) context).refreshView();
						//Logger.e("----", "----------1111111-----");
					} else {
						
//						Intent intent = new Intent();
//						 intent.setClass(context, JddMainActivity.class);
//						 context.startActivity(intent);

						 EventManager.getInstance().onEvent(EventType.EV_UI_FRM_MAIN_JUMP, FrmWorkStatus.HEMAI_CENTER);
//						dialog.dismiss();
//						((JddMainActivity) context).refreshView();
						//Logger.e("----", "-------2222222222-------");
						((Activity)context).setResult(Activity.RESULT_OK);
						((Activity)context).finish();
//						((JddMainActivity)context).refreshView();
					}
					 dialog.dismiss();
				}
			}).setNegativeButton("投注记录", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
//					Intent intent = new Intent();
//					intent.setClass(context, BetRecordActivity.class);
//					context.startActivity(intent);
//					if (context.getClass().equals(HeMaiDetailActivity.class)) {
//						((HeMaiDetailActivity) context).finish();
//					}

					Intent intent = new Intent();
					intent.setClass(context, BetRecordActivity.class);
					context.startActivity(intent);
					
					if (context.getClass().equals(JddMainActivity.class)) {
						((JddMainActivity) context).refreshView();
					} else {
						((Activity)context).setResult(Activity.RESULT_OK);
						((Activity)context).finish();
					}
					 dialog.dismiss();
				}
			}) .setOnCancelListener(new DialogInterface.OnCancelListener() {

				@Override
				public void onCancel(DialogInterface dialog) {
					// TODO Auto-generated method stub
					//Logger.d("vvvvvvvvvv", "------------------------");
					if (context.getClass().equals(HeMaiDetailActivity.class)) {
						((HeMaiDetailActivity) context).refreshActity();
					}
				}})
			.createCustomDialog().show();
		}
		/*Dialog dialog = alertbBuilder.create();
		dialog.setCanceledOnTouchOutside(false);
		dialog.setCancelable(false);// 设置back键是否可以取消
		try{
			dialog.show();
		}catch(Exception e){
//			e.printStackTrace();
		}*/
	}

}
